
<!doctype html>
<html lang="ch">
<head>
	<title>训练日教练列表</title>
	<meta charset="utf-8" />
	<meta name="apple-touch-fullscreen" content="YES" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <meta name="viewport" content="width=320, user-scalable=no">

	<meta http-equiv="Expires" CONTENT="0">
	<meta http-equiv="Cache-Control" CONTENT="no-cache">	
	<meta http-equiv="Pragma" CONTENT="no-cache">

	<link rel="stylesheet" type="text/css" href="/include/main.css" />
  <link rel="stylesheet" href="/css/swiper.min.css">
  <script type="text/javascript" src='/include/jquery.1.10.1.min.js'></script>
  <script type="text/javascript" src='/include/layer.m.js'></script>
  <script src="/js/swiper.min.js"></script>
   
</head>

 
<body>
 
<script src="/js/nano.js"></script>

<div class="swiper-container" id="coachlist-swiper-container">
    <div class="swiper-wrapper">
        <div class="swiper-slide  "><a href="/index.php/courselist"><img src="/images/ad/topad1.jpg" style="width:100%"></a></div>
        <div class="swiper-slide  "><a href="/index.php/register"><img src="/images/ad/topad2.jpg" style="width:100%"></a></div>
        <div class="swiper-slide  "><a href="/index.php/coachlist"><img src="/images/ad/topad3.jpg" style="width:100%"></a></div>
    </div>
     <div class="swiper-pagination"></div>
 </div>

<div class="selebox">
    <ul class="seleul clearfix">
        <li class="class1" padid="1">类别</li>
        <li class="class2" padid="2">筛选</li>
        <li class="class3" padid="3">排序</li>
    </ul>

    <div class="typesele_pad">
         <ul class="typesele_ul pad1">
               <a class="querylink" href="javascript:void(0)" pkey="stype" pval="0">全部</a>
                <a class="querylink " href="javascript:void(0)" pkey="stype" pval="1">健身</a> 
                 <a class="querylink" href="javascript:void(0)" pkey="stype" pval="2">羽毛球</a>
                <a class="querylink" href="javascript:void(0)" pkey="stype" pval="3">网球</a> 
                 <a class="querylink" href="javascript:void(0)" pkey="stype" pval="4">高尔夫</a> 
                <a class="querylink" href="javascript:void(0)" pkey="stype" pval="5">游泳</a>
                 <a class="querylink" href="javascript:void(0)" pkey="stype" pval="6">瑜伽</a> 
                <a class="querylink" href="javascript:void(0)" pkey="stype" pval="7">跑步</a> 
                <a class="querylink" href="javascript:void(0)" pkey="stype" pval="8">兵乓球</a> 
           </ul>

         <ul class="typesele2_ul pad2">
                <li style="display:none">常驻区域
                  <div class="typesele_subpad">
                      <a class="querylink" href="javascript:void(0)" pkey="areaid" pval="0">深圳市</a> 
                      <a class="querylink" href="javascript:void(0)" pkey="areaid" pval="1">南山</a> 
                      <a class="querylink" href="javascript:void(0)" pkey="areaid" pval="2">罗湖</a> 
                  </div>
                </li>
                <li>性别
                  <div class="typesele_subpad">
                      <a class="querylink" href="javascript:void(0)" pkey="sex" pval="0">不限</a> 
                      <a class="querylink" href="javascript:void(0)" pkey="sex" pval="1">男</a> 
                      <a class="querylink" href="javascript:void(0)" pkey="sex" pval="2">女</a>
                  </div>
                </li>
             </ul>

         <ul class="typesele_ul pad3">
               <a class="querylink" href="javascript:void(0)" pkey="sorttype" pval="0">推荐排序</a> 
               <a class="querylink" href="javascript:void(0)" pkey="sorttype" pval="1">价格由低到高</a> 
               <a class="querylink" href="javascript:void(0)"  pkey="sorttype" pval="2">评分由高到低</a> 
         </ul>

    </div>


</div>



<div id="coachlistbox">
    <ul class="coachlistul " id="coachlistul">

      <?php foreach ($coachlist as $coach): ?>
         <li class="clearfix" coachid="<?=$coach->id?>">   
             <div class="coachthumb">
                <img src="<?=$coach->thumb?>"  >
             </div>
             <div class="coachcard">
		            <h3><?=$coach->fullname?></h3>

                <h5>
                <span class="sexandage sag<?=$coach->sex?>"><?=$coach->age?></span>
                 <img src="/images/icon/tag.png" class="subimg"  >  <span class="stypespan"><?=$coach->stypename?></span> 
                <img src="/images/icon/pin.png" class="subimg">  <span class="distspan"> <?=$coach->areaname?></span>
                </h5>
		            <p><?=$coach->description?></p>
		            <h6><span class="redspan">￥<?=$coach->stype_main_price?></span></h6>
                <div class="tagbox" style="display:none">
                     <span>风趣幽默</span><span>英俊潇洒</span>
                </div>
            </div>
          </li>
      <?php endforeach; ?>
  

    </ul>

    <div class="loadmore">更多</div>
</div>


<div style="display:none">
<img src="/images/round_bg.png">
</div>

<script src="/js/main.js"></script>
 

<script>    

 function bindliclick(){
    $("#coachlistul li").on('click',function(){
          var coachid = $(this).attr("coachid");
          location.href="/index.php/coach?id="+coachid;
    });
 }
 bindliclick();


  var mySwiper = new Swiper ('.swiper-container', {
        loop: true,
       // 如果需要分页器
       pagination: '.swiper-pagination',
       paginationClickable: true
   })       

 

   var stype='0';
   var areaid='0';
   var sex='0';
   var sorttype='0';

   var pageno=1;

   $(".loadmore").on('click',function(){

        pageno++;
        var url = "/index.php/coachlist/query?stype="+ stype+ "&areaid=" + areaid + "&sex=" +sex+"&sorttype="+sorttype+"&pageno="+pageno;

        $.getJSON(
             url,
             function(ret){
                 var data = ret.list;
                 showmore(data,0);
             }
         );
   });

   $(".querylink").on('click',function(){

       var pkey = $(this).attr("pkey");
       var pval = $(this).attr("pval");
       //var url = "/index.php/coachlist/query?stype="+ stype+ "&areaid=" + areaid;

       $(".seleul li").removeClass("seled");
       $(".typesele_pad").slideUp();

       $(this).siblings().removeClass("sele");
       $(this).addClass("sele");

       // 
       // if(pval==0){
          
       // }

       // $(".class1").html("<span>"++"</span>");

         var seleval = $(this).html();

         if(pkey=='stype'){
            stype = pval;
            if(stype==0){
                $(".class1").html("类别");
            }else{
                $(".class1").html("<span class=sele_li>"+seleval+"</span>");
            }
         }
         if(pkey=='areaid'){
            areaid = pval;
            $(".class2").html("<span class=sele_li>"+seleval+"</span>");
            if(areaid==0){
                $(".class2").html("筛选");
            }else{
                $(".class2").html("<span class=sele_li>"+seleval+"</span>");
            }
         }
         if(pkey=='sex'){
            sex = pval;
            $(".class2").html("<span class=sele_li>"+seleval+"</span>");
         }
         if(pkey=='sorttype'){
            sorttype = pval;
            if(sorttype==0){
                $(".class3").html("排序");
            }else{
                $(".class3").html("<span class=sele_li>"+seleval+"</span>");
            }
         }


       loadlist(pkey,pval);

   });
 


   function loadlist(pkey,pval){

        var url = "/index.php/coachlist/query?stype="+ stype+ "&areaid=" + areaid + "&sex=" +sex+"&sorttype="+sorttype;
        console.log(url);
        pageno = 1;

        $.getJSON(
             url,
             function(ret){
                 var data = ret.list;
                 showmore(data,1);
             }
         );
   }




   function showmore(listdata,reload){

         var morestr = '';

         for(var i in listdata){ 
           // html+=createItem(data[o].content,data[o].create_time);
             //var morelist = nano("欢迎你{fullname}!",listdata[i]);
             //var mb = " <li class=\"clearfix\"><div class=\"coachthumb\"><img src=\"<?=$coach->thumb?>\"  ></div><div class=\"coachcard\"><h3>{fullname}</h3><h5><span class=\"stypespan\"><?=$coach->stypename?></span><span class=\"distspan\"><?=$coach->areaname?></span></h5> <p><?=$coach->description?></p><h6><span class=\"redspan\">￥<?=$coach->stype_main_price?></span></h6></div></li>";
             
var mb = "<li class=\"clearfix\" coachid=\"{id}\"><div class=\"coachthumb\"><img src=\"{thumb}\"  ></div><div class=\"coachcard\"><h3>{fullname}</h3><h5><span class=\"sexandage sag{sex}}\">{age}</span><img src=\"/images/icon/tag.png\" class=\"subimg\"  >  <span class=\"stypespan\">{stypename}</span> <img src=\"/images/icon/pin.png\" class=\"subimg\"><span class=\"distspan\"> {areaname}</span></h5><p>{description}</p><h6><span class=\"redspan\">￥{stype_main_price}</span></h6><div class=\"tagbox\" style=\"display:none\"><span>风趣幽默</span><span>英俊潇洒</span></div></div></li>";



             var morelist = nano(mb,listdata[i]);
             morestr = morestr + morelist;

          } 

          if(reload == 1){
               $("#coachlistul").html(morestr);
          }else{
               $("#coachlistul").append(morestr);
          }

           bindliclick();
 
         // var html = "";
         // for(var o in data){ 
         //    html+=createItem(data[o].content,data[o].create_time);
         // } 
         // $('#list').append(html);  
         // setTimeout(function () { setLoading(); }, 1000);
         // $(".listitem:last").css("border-bottom","0px");
   }




 
</script>
 

</body>
</html>